package com.dhcc.demo.api.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.dhcc.core.api.annotion.ApiPermission;
import com.dhcc.core.api.controller.BaseApiController;
import com.dhcc.core.framework.result.R;
import com.dhcc.core.modules.system.entity.User;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

/**
 * API测试接口
 * 
 * @ClassName: ApiTestController
 * @Description: TODO
 * @author: cyf
 * @date: 2018年1月2日 上午10:04:55
 */
@RestController
@RequestMapping("${sys.apiPath}")
@Api("测试接口")
public class ApiTestController extends BaseApiController {

    /**
     * 获取用户信息
     */
    @GetMapping("user_info")
    @ApiOperation(value = "获取用户信息")
    @ApiImplicitParam(paramType = "header", name = "Authorization", value = "Authorization", required = true)
    @ApiPermission("api:test:user")
    public R userInfo() {
        User user = this.getLoginUser();
        return R.ok().put("user", user);
    }

    /**
     * 忽略Token验证测试
     */
    @GetMapping("notToken/{text}")
    @ApiOperation(value = "忽略Token验证测试")
    @ApiImplicitParam(paramType = "path", name = "text", value = "text", required = true)
    public R notToken(@PathVariable String text) {
        return R.ok().put("msg", "无需token也能访问。。。" + text);
    }
    
}
